package com.example.flashsales.service.impl;

import com.example.flashsales.entity.vo.UserVo;
import com.example.flashsales.mappers.UserRecordMapper;
import com.example.flashsales.service.UserRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserRecordServiceImpl implements UserRecordService {

    @Autowired
    UserRecordMapper userRecordMapper;

    @Autowired
    UserServiceImpl userService;
    /**
     *  增加一条拉人纪录
     * @param userId 用户id
     * @param storeId 店家id
     * @return 返回是否增加成功
     */
    @Override
    public boolean addRecord(long userId, long storeId) {
        final UserVo userVo = userService.viewUserMessage(userId);

        return userRecordMapper.addRecord(userId,storeId) > 0;
    }


    /**
     * 找出店家拉人的用户id集合
     * @param storeId 店家id
     * @return 返回用户id集合
     */
    @Override
    public List<Integer> viewUserIdByStore(long storeId) {
        return userRecordMapper.viewUserIdByStore(storeId);
    }
}
